home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / pistol.zip / PISTE.C < prev    next >
Text File  |  1987-08-20  |  2KB  |  95 lines

  1. /*********************************************************/
  2. /*                             */
  3. /* PISTOL-Portably Implemented Stack Oriented Language     */
  4. /*            Version 1.3             */
  5. /* (C) 1982 by    Ernest E. Bergmann             */
  6. /*        Physics, Building #16             */
  7. /*        Lehigh Univerisity             */
  8. /*        Bethlehem, Pa. 18015             */
  9. /*                             */
  10. /* Permission is hereby granted for all reproduction and */
  11. /* distribution of this material provided this notice is */
  12. /* is included.                         */
  13. /*                             */
  14. /*********************************************************/
  15.  
  16. /* fifth module, February, 1982 */
  17.  
  18. #include "bdscio.h"
  19. #include "pistol.h"
  20.  
  21. int *find(ptoken) /*returns address of dict'ary word or FALS*/
  22. int *ptoken; /* string to be looked up;"int" more efficient*/
  23. {int *loc,*v;
  24.     for(loc=FALS,v=ram[-32].pw;(v>&ram[VBASE-1])
  25.                     && !loc ;v--)
  26.         loc=vfind(ptoken,v);
  27.     return(loc);
  28. }
  29.  
  30. int *vfind(ptoken,v)
  31. int *ptoken,*v;
  32. {/*vloc &vmatch are at end of pist.h*/
  33.     vloc=*v; vloc=*vloc;
  34.     if(vloc) do
  35.     {vmatch=FALS;
  36.     if(Pw=*(vloc-2),*Pw==*ptoken)
  37.         vmatch=pstrcmp(ptoken);
  38.     if(!vmatch)
  39.         vloc=*(vloc-3);
  40.     }
  41.     while(vloc && !vmatch);
  42.     return(vloc);
  43. }
  44.  
  45. char pstrcmp(str2) /* returns FALS if not a PISTOL string
  46.                 match*/
  47. char *str2;
  48. {/*char pcount,*Pc3; is at end of pist.h*/
  49.     Pc3=Pw;
  50.     pcount=*Pc3; Pc3++ ; str2 ++ ;
  51.     for(; pcount ; --pcount,++Pc3,++str2)
  52.         if(*Pc3 != *str2) break;
  53.     return( !pcount );
  54. }
  55.  
  56. intoken() /* Feb 13 remove need for ptr,partly ptr2 */
  57. {char count,*ptr2;
  58.     ptr2=ram[-4].pc;
  59.     for(count=0;!white(*ram[-15].pc);nextch())
  60.     {    count++ ; ptr2++ ;
  61.         if(ram[-17].in) *ptr2=toupper(*ram[-15].pc) ;
  62.         else *ptr2 =*ram[-15].pc ;
  63.     }
  64.     *ram[-4].pc=count ;
  65. }
  66.  
  67. nextch() /* Feb 13 removed Pc crutch */
  68. {if (*ram[-15].pc != NEWLINE) ram[-15].pc++ ; }
  69.  
  70. ignrblnks() /* Feb 13 removed Pc crutch */
  71. {    while((*ram[-15].pc==9)
  72.         ||(*ram[-15].pc==32)) ram[-15].pc++ ;
  73. }
  74.  
  75. prompt()
  76. {if(ram[-50].pw) interpret(ram[-50].pw);
  77. else    {if(ram[-24].in) carret();
  78.     if(ram[-14].in) putch(strings[0]);
  79.     message(&strings[1]);
  80.     if(ram[-14].in) puts("> ");
  81.     if(ram[-12].in)fputs("> ",list);
  82.     }
  83. }
  84.  
  85. int white(c)    /* better than isspace(c) */
  86. char c;
  87. {    if(c==32) return(TRU);
  88.     if(c==9)  return(TRU);
  89.     if(c==NEWLINE)
  90.           return(TRU);
  91.     return(c==0);
  92. }
  93.  
  94. ; is at end of pist.h*/
  95.     Pc3=Pw